home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue40 / Threads / HVUtils.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-11-03  |  839 b   |  46 lines

  1. unit HVUtils;
  2. //
  3. // Written by Hallvard Vassbotn, hallvard@falcon.no
  4. //
  5. // Based on source code Copyright (c) 1998 by Reuters Group PLC
  6. // Reproduction and/or distribution of source code or DCUs strictly prohibited.
  7. //
  8. // For publication in The Delphi Magazine only
  9. //
  10. interface
  11.  
  12. uses
  13.   Classes;
  14.  
  15. function FreeObject(var AnObject): boolean;
  16. procedure FreeOwningTList(var List: TList);
  17.  
  18.  
  19. implementation
  20.  
  21. function FreeObject(var AnObject): boolean;
  22. var
  23.   Item: TObject absolute AnObject;
  24.   Tmp : TObject;
  25. begin
  26.   Tmp := Item;
  27.   Item := nil;
  28.   Result := Assigned(Tmp);
  29.   Tmp.Free;
  30. end;
  31.  
  32. procedure FreeOwningTList(var List: TList);
  33. var
  34.   i : integer;
  35. begin
  36.   if Assigned(List) then
  37.   begin
  38.     for i := 0 to List.Count-1 do
  39.       FreeObject(List.List^[i]);
  40.     FreeObject(List);
  41.   end;
  42. end;
  43.  
  44.  
  45. end.
  46.